import pandas as pd

# 1. 对数据进行描述性统计分析
# 2. 返回缺失值个数、最大值、最小值

# 文件路径
datafile_test = './data/test.csv'  # test原始数据，第一行为属性标签
datafile_train = './data/train.csv'  # train原始数据，第一行为属性标签

# 读取训练样本和测试样本
data_train = pd.read_csv(datafile_train)
data_test = pd.read_csv(datafile_test)

# 训练样本的描述性统计分析
explore_train = data_train.describe(percentiles=[], include='all').T
# percentiles参数是指定计算多少的分位数表（如1/4分位数、中位数等）
# print(explore_train)

# 计算缺失值
explore_train['null'] = data_train.isnull().sum()
# print(explore_train['null'])
explore_train = explore_train[['null', 'max', 'min']]
explore_train.columns = ['空值数', '最大值', '最小值'] # 表头重命名
# print(explore_train)

# 测试样本的描述性统计分析
explore_test = data_test.describe(percentiles=[], include='all').T
explore_test['null'] = data_test.isnull().sum()
explore_test = explore_test[['null', 'max', 'min']]
explore_test.columns = ['空值数', '最大值', '最小值']
print(explore_test)
